﻿using Shop.RemoteModel.AttrTemplate;
using Shop.RemoteModel.AttrTemplate.Model;
using Shop.Service.Interface;
using WeDonekRpc.Client.Interface;

namespace Shop.Service.RpcEvent
{
    internal class AttrTemplateEvent : IRpcApiService
    {
        private readonly IAttrTemplateService _Service;

        public AttrTemplateEvent (IAttrTemplateService service)
        {
            this._Service = service;
        }

        public long AddAttrTemplate (AddAttrTemplate add)
        {
            return this._Service.Add(add.Datum);
        }
        public Dictionary<long, int> SetAttrTemplateSort (SetAttrTemplateSort obj)
        {
            return this._Service.SetSort(obj.Id, obj.Sort);
        }

        public void DeleteAttrTemplate (DeleteAttrTemplate obj)
        {
            this._Service.Delete(obj.Id);
        }

        public void EnableAttrTemplate (EnableAttrTemplate obj)
        {
            this._Service.Enable(obj.Id);
        }

        public AttrTemplate GetAttrTemplate (GetAttrTemplate obj)
        {
            return this._Service.Get(obj.Id);
        }

        public AttrTemplateTree[] GetAttrTemplateTree (GetAttrTemplateTree obj)
        {
            return this._Service.GetTrees(obj.CategoryId, obj.IsEnable);
        }

        public void StopAttrTemplate (StopAttrTemplate obj)
        {
            this._Service.Stop(obj.Id);
        }

        public bool SetAttrTemplate (SetAttrTemplate set)
        {
            return this._Service.Update(set.Id, set.Datum);
        }
    }
}
